<template>
	<view>
		<view class="top">
			<image class="tiaozhuan" src="../../../static/images/ljh/jt.png" @click="returnButton()"></image>
			<view class="title">救援记录</view>
		</view>
		<view class="cont">
			<view v-for="(item, index) in recordList" :key="index" class="jyzItem">
				<uni-card :title="typeList[item.type]" :extra="item.rescueTime" style="border-radius: 20rpx;">
					<view class="contitem">
						<view class="itemhead">
							订单编号：
						</view>
						<view class="itemcont">
							{{item.id}}
						</view>
					</view>
					<view class="contitem" v-if="item.type == 3">
						<view class="itemhead">
							起点：
						</view>
						<view class="itemcont">
							{{item.start}}
						</view>
					</view>
					<view class="contitem" v-if="item.type == 3">
						<view class="itemhead">
							终点：
						</view>
						<view class="itemcont">
							{{item.end}}
						</view>
					</view>
					<view class="contitem" v-if="item.type != 3">
						<view class="itemhead">
							位置：
						</view>
						<view class="itemcont">
							{{item.address}}
						</view>
					</view>
					<view class="contitem">
						<view class="itemhead">
							车牌：
						</view>
						<view class="itemcont">
							五菱宏光
						</view>
					</view>
				</uni-card>
			</view>
			
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				typeList: {
				    "1": '搭电',
				    "2": '换胎',
				    "3": '拖车'
				},
				//	救援记录列表
				recordList:[],
				
				
				selectForm:{
					userId:''
				}
			}
		},
		onLoad(){
			this.getRecord();
			this.aroundShop()
		},
		methods: {
			aroundShop(){
				this.$http({
					url: '/api/shop/manage/list',
					method: 'GET',
					success(res){
						console.log(res.data);
					}
				})
			},
			
			getRecord(){
				this.selectForm.userId = uni.getStorageSync('user_id');
				let that = this;
				this.$http({
					url: '/api/jiuyvanrenwu/jiuyvanrenwu/list',
					method: 'get',
					data: this.selectForm,
					success(res){
						// console.log(res.data.rows);
						res.data.rows.forEach(item=>{
							that.recordList.push({
									id:item.id,
									type:item.type,
									start:item.start,
									end:item.end,
									address:item.address,
									rescueTime:item.rescueTime,
								})
						})
						
						// console.log(that.recordList);
					}
				})
			},
			
			
			
			returnButton() {
				// uni.$u.route('/pages/index/index')
				uni.$u.route({
					url: '/pages/index/index',
					type: 'tab'
				})
			}
			
		}
	}
</script>

<style>
	.tiaozhuan {
		position: absolute;
		color: white;
		font-size: 50rpx;
		top: 50rpx;
		left: 20rpx;
		width: 50rpx;
		height: 50rpx;
	}

	.cont {
		position: absolute;
		top: 200rpx;
		width: 100%;
	}

	.itemhead {
		font-weight: bolder;
	}

	.contitem {
		display: flex;
	}

	.title {
		width: 100%;
		color: white;
		text-align: center;
		padding: 50rpx 0rpx;
		font-size: 35rpx;
	}

	.top {
		width: 100%;
		height: 450rpx;
		background-image: url(@/static/images/ljh/tc1.png);
	}
</style>